#include "GlobalVariables.h"

GlobalVariables* GlobalVariables::m_pGlobalVariables = nullptr;

GlobalVariables::GlobalVariables():
	m_Score(0),
	m_HighScore(0),
	m_Speed(20.0f)
{
}

GlobalVariables::~GlobalVariables()
{
}

GlobalVariables* GlobalVariables::GetInstance()
{
	if(m_pGlobalVariables == nullptr)
	{
		m_pGlobalVariables = new GlobalVariables();
	}
	return m_pGlobalVariables;
}

void GlobalVariables::AddScore(int blocks, int multiplier)
{
	for(int i = 0; i < blocks; ++i)
	{
		uint64 scoreAdded = (SCORE_BASE_VALUE + SCORE_EXTRA_VALUE * i) + (m_Score / 800);
		m_Score += scoreAdded * (m_Speed - 19.0f);

		if(m_Score > MAX_SCORE)
		{
			m_Score = MAX_SCORE;
		}
	}
}

uint64 GlobalVariables::GetScore() const
{
	return m_Score;
}

uint64 GlobalVariables::GetHighScore() const
{
	return m_HighScore;
}

void GlobalVariables::SetScore(uint64 score)
{
	m_Score = score;
}

void GlobalVariables::SetHighScore(uint64 highScore)
{
	m_HighScore = highScore;
}
